package loads

import "jvmgo/ch09/instructions/base"
import "jvmgo/ch09/rtda"

//从局部变量表中加载int值
type ILOAD struct {
    base.Index8Instruction
}

//推入指定数值到栈帧中的操作数栈
func (self *ILOAD) Execute(frame *rtda.Frame) {
    _iload(frame, uint(self.Index))
}

type ILOAD_0 struct {
    base.NoOperandsInstruction
}

func (self *ILOAD_0) Execute(frame *rtda.Frame) {
    _iload(frame, 0)
}

type ILOAD_1 struct {
    base.NoOperandsInstruction
}

func (self *ILOAD_1) Execute(frame *rtda.Frame) {
    _iload(frame, 1)
}

type ILOAD_2 struct {
    base.NoOperandsInstruction
}

func (self *ILOAD_2) Execute(frame *rtda.Frame) {
    _iload(frame, 2)
}

type ILOAD_3 struct {
    base.NoOperandsInstruction
}

func (self *ILOAD_3) Execute(frame *rtda.Frame) {
    _iload(frame, 3)
}

//推入指定数值到栈帧中的操作数栈
func _iload(frame *rtda.Frame, index uint) {
    val := frame.LocalVars().GetInt(index)
    frame.OperandStack().PushInt(val)
}
